<?php
function strleft($s1, $s2)
{
    return substr($s1, 0, strpos($s1, $s2));
}

function selfSite()
{
    $s = empty($_SERVER["HTTPS"]) ? '': ($_SERVER["HTTPS"] == "on") ? "s" : "";
    $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
    $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
    return $protocol."://".$_SERVER["SERVER_NAME"].$port;
}

function strToUrl($url)
{
    $url = urldecode(trim($url));
    return strtolower(str_replace(" ", "_", $url));
}

function createUrl($endPart)
{
    return selfSite()."/$endPart";
}

function createPagePath($name)
{
    $path = selfSite();
    $name = strToUrl($name);

    if(stripos($path, "/pages"))
    {
        return $path."/$name";
    }

    return $path."/pages/$name";
}

function styledText($color, $size, $text)
{
    $sText = "<div style=\"color: $color; font-size: $size\">
                $text
              </div>";

    return $sText;
}
?>
